package components;

import entities.Entity;
import game.SpecuspaceException;

import java.awt.geom.Rectangle2D;

import util.Vector2D;


public class ViewBasedCollisionModel extends CollisionModel {

	public ViewBasedCollisionModel(Entity e) {
		super(e);
	}

	@Override
	public Rectangle2D getAABB() {
		EntityView view = entity.getEntityView();
		if (view == null)
			throw new SpecuspaceException(
					"Can't calculate AABB - no view selected");
		Vector2D p = view.getPosition();
		float w = view.getWidth();
		float h = view.getHeight();
		return new Rectangle2D.Float(p.getX(), p.getY(), w, h);
	}

}
